using UnityEngine;
using System.Collections;

public class ZigZag : MonoBehaviour
{
	
	public int Life;
	public float Velocity;
	
	void Update()
	{
		rigidbody.velocity = new Vector3(Velocity, 0.0f, 0.0f);
	}
	
	void OnTriggerEnter(Collider collider)
	{
		switch (collider.name)
		{
		case "Floor":
		case "Side":
			Velocity *= -1;
			break;
		case "Bullet":
			Life--;
			if (Life <= 0)
				Destroy(gameObject);
			break;
		case "Player":
			Destroy(gameObject);
			break;
		}
	}
	
}
